<?php
defined('IN_PHPCMS') or exit('No permission resources.');
class index {
	function __construct() {
        pc_base::load_app_func('global');
        $this->db = pc_base::load_model('ask_model');
		
	}
	
	public function init() {
		include template('ask', 'index');
    }

    public function add(){
        if(isset($_POST['dosubmit'])){
            $username = safe_replace(strip_tags($_POST['username']));
            $phone = safe_replace(strip_tags($_POST['phone']));
            
			$question = safe_replace(strip_tags($_POST['question']));
            $q_time = SYS_TIME;
            $sql = array('username'=>$username,'phone'=>$phone,'question'=>$question,'q_time'=>$q_time);
            // echo "<pre>";
            // print_r($sql);
            // exit;
            $res = $this->db->insert($sql);
            if(!$res) return false;
 			showmessage("提问成功，请等待老师回复...", "?m=ask&c=index&siteid=$siteid");
        }
    }
}